Safe metaclass composition using mixin-based inheritance

نویسنده

  • Noury Bouraqadi
چکیده

In the context of meta-programming and reflective languages, classes are treated as full fledged objects which are instances of other classes named metaclasses. Metaclasses have proved to be useful for defining new class properties. Examples of such properties are lazy memory allocation, multiple inheritance, having a single instance. . . A class with some property is obtained by instantiating a metaclass which implements the desired property. However, instantiation allows assigning to a class only properties defined by a single metaclass. A composition mechanism is needed to reuse properties defined by different metaclasses and assign them to a given class. This composition should be performed without breaking class-metaclass compatibility. The compatibility issue arises when a class is coupled to its metaclass. So, when composing metaclasses, we need to take care of such coupling to avoid run-time exceptions. In this paper, we explore the use of mixin-based inheritance to perform metaclass composition. Mixin-based inheritance is an interesting alternative to both single and multiple inheritance. As opposite to single inheritance, it allows reusing code among different class hierarchies. Contrary to multiple inheritance, it allows developers to explicitly specify the desired behavior through explicit linearizations. Our proposal is to define and compose reusable class properties by introducing mixins at the metaclass level. We demonstrate that this introduction can be done efficiently without altering compatibility.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Uniform and safe metaclass composition

In pure object-oriented languages, classes are objects, instances of other classes called metaclasses. In the same way as classes define the properties of their instances, metaclasses define the properties of classes. It is therefore very natural to wish to reuse class properties, utilizing them amongst several classes. However this introduced metaclass composition problems, i.e., code fragment...

متن کامل

Modular Inheritance of Objects Through Mixin-Methods

In object-oriented programming languages the class concept is heavily overworked. To simplify things, there is a tendency to unbundle the different roles they play by trying to create more modular inheritance operators [Bracha&Lindstrom92]. This offers the advantage that classes can be composed in a modular way. Prototype-based languages on the other hand, also provide a simpler view on object-...

متن کامل

Safe and Explicit Composition of Class Properties

As object-oriented programmers, we are trained to capture common properties of objects in classes that can be reused. Similarly, we would like to capture common properties of classes in metaclass properties that can be reused. This goal has led researchers to propose models based on explicit metaclasses, but this has opened Pandora’s box leading to metaclass composition problems. Numerous appro...

متن کامل

A Constraint-Driven Executable Model of Dynamic System Reconfiguration

Dynamic system reconfiguration techniques are presented that can enable the systematic evolution of software systems due to unanticipated changes in specification or requirements. The methodological approach is based upon a domain analysis, which identifies a set of concepts that reflect the types of reconfigurations possible and the system integrity characteristics that must be maintained duri...

متن کامل

Subtyping-inheritance Conflicts: the Mobile

In sequential classand mixin-based settings, subtyping is essentially a relation on objects: no subtype relation is defined on classes and mixins, otherwise there would be conflicts with the inheritance mechanism, creating type un-safety. Nevertheless, a width-depth subtyping relation on class and mixin types is useful in the realm of mobile and distributed processes, where object-oriented code...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:
  • Computer Languages, Systems & Structures

دوره 30  شماره 

صفحات  -

تاریخ انتشار 2004